package com.filldream.fastboot.common.entity;

import lombok.Data;
import lombok.experimental.Accessors;

import java.util.regex.Matcher;

@Accessors(chain = true)
@Data
public class ErrContent {

    //基本错误码
    private ErrorCode errorCode;

    //具体返回的msg
    private String content;

    /**
     * 替换占位符
     * @param text  自定义信息
     */
    public void reMsg(String text){
       String tempMsg = errorCode.getMsg();
       this.content = tempMsg.replaceAll( "%s",":" + Matcher.quoteReplacement(text) );
    }

    public String getMsg(){
        return this.content;
    }

    public int getCode(){
        return this.errorCode.getCode();
    }

    public String getEnMsg(){
        return this.errorCode.getEnMsg();
    }

}
